// pages/qiye_jieshao/qiye_jieshao.js
const app = getApp()
//获得全局js变量
var util = require('../../utils/util.js');
Page({
    data: {
        info: [],
        id: 0,
        userinfo: []
    },
    onLoad(options) {
        this.setData({
            id: options.id,
            userinfo: wx.getStorageSync('user')
        });
        this.getinfo();
    },
    getinfo() {
        const that = this;
        util.httpRrquest(app.data.apiurl + 'shop/getMyshop', 'GET', { id: that.data.id,
                cateId: that.data.navType,
                year: that.data.year,
                month: that.data.month })
        .then(function (response) {
            var data = response.data.data;
            that.setData({
                info: data.data
            });
        }, function (error) {
            console.log(error);
        });
        
    },
    toNum(event) {
        const index = event.currentTarget.dataset.index;
        wx.navigateTo({
            url: '/pages/caiGouNum/caiGouNum?navType='+index+'&type=2&id='+this.data.id
        });
    },
    shenhe(event) {
        const that = this;
        const index = event.currentTarget.dataset.index;
        wx.showModal({
            title: '提交审核',
            content: '确认提交审核吗？不可撤回',
            success(res) {
                if (res.confirm) {
                    util.httpRrquest(app.data.apiurl + 'shop/addButie', 'GET', { id: that.data.id,
                            index: index})
                    .then(function (response) {
                        that.getinfo();
                    }, function (error) {
                        console.log(error);
                    });

                    
                }
            }
        });
    }
});